package SliceHelper

import (
	"fmt"
	"strings"
)

//int 切片转字符串  以","分隔
func SliceIntToString(data []int) string {
	var separator = ","
	return strings.Replace(strings.Trim(fmt.Sprint(data), "[]"), " ", separator, -1)
}

/**
字符串切片转字符串
 */
func SliceToString(data []string) string  {
	var separator = ","
	return strings.Join(data, separator)
}


/**
字符切片去重
*/
func SliceUniqueString(input []string) []string {
	result := []string{}
	// 存放不重复主键
	tempMap := map[string]byte{}
	for _, e := range input {
		l := len(tempMap)
		tempMap[e] = 0
		if len(tempMap) != l {
			// 加入map后，map长度变化，则元素不重复
			result = append(result, e)
		}
	}
	return result
}